package com.margo.project.cors.service;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class SocketService {
	public static void main(String[] args) throws IOException {
		//int port = 8091;
		int port=8081;
		@SuppressWarnings("resource")
		ServerSocket server = new ServerSocket(port);
		while (true) {
	         //server尝试接收其他Socket的连接请求，server的accept方法是阻塞式的
	         Socket socket = server.accept();
	         //每接收到一个Socket就建立一个新的线程来处理它
	         new Thread(new ServiceHandleTask(socket)).start();
	    }

	}
}
